<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>城配附加信息页面</title>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 70px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
         <div class="fieldset1  clearFix">
            <div class="clearFix"></div>
            <div class="btnsBox formBtns notRight">
                <c:if test="${exposureSource == 1 || exposureSource == 2}">
					<sys:funcAuth resCd="statistical">
                    	<span id="statistical" class="sq-button sq-button-round" onclick="statistical();" >敞口统计</span>
					</sys:funcAuth>
                </c:if>
            	<c:if test="${(spFlag!=1 && dyFlag!=1) || prjTypCd == 'CDDYWYQ'}">
	                <span id="exportbtn" class="sq-button-round" onclick="toPrjFileInfo();">项目资料</span>
            	</c:if>
		    	 <c:if test="${EmergencyContact == 1 }">
					<span id="" class="sq-button sq-button-round" onclick="addEmergencyContact();">添加第三方联系人</span>
				</c:if>
				 <c:if test="${returnvisit == 1 }">
					<span id="" class="sq-button sq-button-round" onclick="toFlowVisitAdd();">后续回访记录</span>
				</c:if>
				<c:if test="${authNm ==1 }">
					<div class="fieldBox col_100">
		            <div class="label">  
		              <span style="width:400px">抵押权人修改</span>
		            </div>
		            <div class="field">
		            	<select name="pledgeeAuthNm" id="pledgeeAuthNm" data-value="">
		                	<c:forEach items="${pledgeeNmList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
						 <span id="addpledgeeAuthNmBtn" class="sq-button sq-button-round" onclick="addpledgeeAuthNm();" >保存</span>
		            </div>
		        </div>
		       
		        </c:if>
	
            </div>
        </div>
    </form>
</div>
    <div id="ligergrid1" class="sq-grid"></div>
	<%-- 项目风险审核提醒 --%>
	<div id="prjRskAudWarnDiv" style="display:none">
		<div class="caption">
			<span class="title">项目风险审核提醒</span>
		</div>
		<div id="prjRskAudWarnInfo" class="fieldBox col_100">
			<div class="sqPanel">
				<div class="sqPanel_body">
					<div id="ligergrid_prjRskAudWarn" class="sq-grid"></div>
					<span id="tips" class="requiredSymbol">评审流程为各事业部通知政策约束的OA流程;详情可咨询事业部风险总监;</span>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
var exposureSource = '${exposureSource}';
var grid = null;
var prjId = '${prjId}';
var checkSp = '${checkSp}';
var checkDy = '${checkDy}';
var confirmPay = '${confirmPay}';
var authNm = '${authNm}'; //抵押权人添加/查看标识
var authNmFlag = false;
var isAdvBiz = '${isAdvBiz}';
var assetCd = '${assetCd}';
//是否展示项目风险审核提示
var showPrjRskAudWarn = '${showPrjRskAudWarn}';
var prjRskAudWarnGrid = null;
$(function () {//由于添加了抵押权人修改，在信审审核抵押节点，列表变为复选框。
	if(authNm == 1){
		authNmFlag = true;
	}
	payFlowadd();
	if (null != isAdvBiz && 1 == isAdvBiz) {
		$("span.sq-button").hide();
	}
	//展示项目风险审核提醒
	ctrlPrjRskAudWarnShow();
});
function payFlowadd(){
	 grid = $("#ligergrid1").ligerGrid({
	        url: '<%=path%>/capital/capPayInfo/initList.do?isCpFlow=1&payTypCd=2&isAllAuth='+assetCd+'&prjId='+prjId,
	        method: 'get',
	        columns: [
	            {display: '客户名称', name: 'cstNm', width: 100, enabledSort: false},
	            {display: '合同号', name: 'contNo', width: 120, align: 'left', enabledSort: false},
	            {display: '支付表号', name: 'paySchNo', width: 150, align: 'left', enabledSort: false},
	            {display: '放款金额', name: 'payAmt', width: 80, align: 'right', enabledSort: false,
	                render:function(rowdata,index,value){
	                    return '&yen;'+FormatMoney(rowdata.payAmt/100);
	                }
	            },
	            {display: '实际放款金额', name: 'actPayAmt', width: 100, align: 'right', enabledSort: false,
	                render:function(rowdata,index,value){
	                    if(rowdata.actPayAmt){
	                        return '&yen;'+FormatMoney(rowdata.actPayAmt/100);
	                    }
	                }
	            },
	            {display: '实际付款时间', name: 'actPayTm', width: 100, align: 'left', enabledSort: false,render:renderDate},
	            {display: '放款状态', name: 'payStsCdNm', width: 80, align: 'center', enabledSort: false},
	            {display: '项目类型', name: 'prjTypCdNm', width: 100, align: 'center', enabledSort: false},
	            {display: '客户经理', name: 'cstMgrNm', width: 80, align: 'center', enabledSort: false},
	            {
		         	display: '操作',minWidth: 250,align:'left',
		         	render: function (rowdata, rowindex, value){
		         		var h='<a class="sq-button-hasicon" href="javascript:toPayFlowAdditionalPage(';
		              	    h+="'"+rowdata.id+"'";
		              	  	<c:if test="${zjlFlag == 1 }">
			              		h+=')"><i class="sqBtnIco_6"></i>修改</a>';
		              	  	</c:if>
		              	  	<c:if test="${zjlFlag != 1 }">
			              		h+=')"><i class="sqBtnIco_6"></i>审核</a>';
		              	  	</c:if>
	              		var c = "";
	              		if(confirmPay==1&&rowdata.prjTypCd=="CPYW"){
		              		if(rowdata.payStsCd && rowdata.payStsCd==2){
			         		 	c='<a class="sq-button-hasicon" href="javascript:cancelPay(';
			              	    c+="'"+rowdata.id+"'";
			              		c+=')"><i class="sqBtnIco_14"></i>取消放款<span style="color: red;">  取消后无法恢复!</span></a>';
		              		}
	              		}
		              	var sp = "";
		              	if(spFlag==1){
							if(rowdata.spState=="0"){
			              		if(rowdata.isExistSp=="1"){
				         		 	sp='<a class="sq-button-hasicon" href="javascript:modifySp(';
				         		 	sp+="'"+rowdata.prjPrdDtlId+"'";
				         		 	sp+=')"><i class="sqBtnIco_4"></i>修改上牌信息</a>';
			              		}else{
			              			sp='<a class="sq-button-hasicon" href="javascript:addSp(';
			              			sp+="'"+rowdata.prjPrdDtlId+"'";
			              			sp+=')"><i class="sqBtnIco_3"></i>添加上牌信息</a>';
			              		}
							}else if(rowdata.spState=="1"){
								sp+='<a class="sq-button-hasicon" href="javascript:showSp(';
		              			sp+="'"+rowdata.prjPrdDtlId+"'";
		              			sp+=')"><i class="sqBtnIco_2"></i>已上牌</a>';
							}
		              	}
		              	var dy = "";
		              	if(dyFlag==1){
		              		//h="";
		              		if(rowdata.dyState=="0"){
			              		if(rowdata.isExistDy=="1"){
			              			dy='<a class="sq-button-hasicon" href="javascript:modifyDy(';
			              			dy+="'"+rowdata.prjPrdDtlId+"'";
			              			dy+=')"><i class="sqBtnIco_4"></i>修改抵押信息</a>';
			              		}else{
			              			dy='<a class="sq-button-hasicon" href="javascript:addDy(';
			              			dy+="'"+rowdata.prjPrdDtlId+"'";
			              			dy+=')"><i class="sqBtnIco_3"></i>添加抵押信息</a>';
			              		}
		              		}else if(rowdata.dyState=="1"){
		              			dy+='<a class="sq-button-hasicon" href="javascript:showDy(';
		              			dy+="'"+rowdata.prjPrdDtlId+"'";
		              			dy+=')"><i class="sqBtnIco_2"></i>已抵押</a>';
		              		}
		              	}
		              	var check = "";
		              	if(checkSp==1){
		              		if(rowdata.isExistSp=="1" && rowdata.spState=="0"){
		              			check+='<a class="sq-button-hasicon" href="javascript:showSp(';
		              			check+="'"+rowdata.prjPrdDtlId+"'";
		              			check+=')"><i class="sqBtnIco_38"></i>校验上牌</a>';
		              		}else if(rowdata.spState=="1"){
		              			check+='<a class="sq-button-hasicon" href="javascript:showSp(';
		              			check+="'"+rowdata.prjPrdDtlId+"'";
		              			check+=')"><i class="sqBtnIco_2"></i>已上牌</a>';
		              		}
		              	}
		              	if(checkDy==1){
		              		if(rowdata.isExistDy=="1" && rowdata.dyState=="0"){
		              			check+='<a class="sq-button-hasicon" href="javascript:showDy(';
		              			check+="'"+rowdata.prjPrdDtlId+"'";
		              			check+=')"><i class="sqBtnIco_38"></i>校验抵押</a>';
		              		}else if(rowdata.dyState=="1"){
		              			check+='<a class="sq-button-hasicon" href="javascript:showDy(';
		              			check+="'"+rowdata.prjPrdDtlId+"'";
		              			check+=')"><i class="sqBtnIco_2"></i>已抵押</a>';
		              		}
		              	}

		              return h+c+sp+dy+check;
		         	}
	            }
	        ],
	        pageSize: 100,
	        root: 'rows',
	        record: 'total',
	        hideLoadButton: true,
	        width: '100%',
	        height: '100%',
	        heightDiff: -2,
            checkbox: authNmFlag,
	        rownumbers: true,
	        allowUnSelectRow: true,
	        alternatingRow: true
	    });
	    grid.setHeight(100);
}
/**新增上牌信息*/
function addSp(_prjPrdDtlId){
	if(!_prjPrdDtlId)return;
	var detailFlag = false;
	//调上牌维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'sp_info_add','添加上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage.do?isFlow=1&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId,callback);
}
/**修改上牌信息*/
function modifySp(_prjPrdDtlId){
	if(!_prjPrdDtlId)return;
	var detailFlag = false;
	//调上牌维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'sp_info_add','修改上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage.do?isFlow=1&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId+'&id='+_prjPrdDtlId,callback);
}
/**查看上牌信息*/
function showSp(_prjPrdDtlId){
	var detailFlag = true;
	//调上牌维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'sp_info_add','查看上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage.do?isFlow=1&checkSp=${checkSp}&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId+'&id='+_prjPrdDtlId, callback);
}
/**新增抵押信息*/
function addDy(_prjPrdDtlId){
	if(!_prjPrdDtlId)return;
	var detailFlag = false;
	//调抵押维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'dy_info_add','添加抵押信息','<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=1&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId,callback);
}
/**修改抵押信息*/
function modifyDy(_prjPrdDtlId){
	if(!_prjPrdDtlId)return;
	var detailFlag = false;
	//调抵押维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'dy_info_add','修改抵押信息','<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=1&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId+'&id='+_prjPrdDtlId,callback);
}
/**查看抵押信息*/
function showDy(_prjPrdDtlId){
	var detailFlag = true;
	//调抵押维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
	Add_navTab( 'dy_info_add','查看抵押信息','<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=1&checkDy=${checkDy}&detailFlag='+detailFlag+'&dtlId='+_prjPrdDtlId+'&id='+_prjPrdDtlId, callback);
}

	function cancelPay(_capPayId){
		if(!_capPayId)return;
		
		$.ligerDialog.confirm("<span style='color: red;'>确定取消此支付表的放款吗?取消后无法恢复!</span>", function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{capPayId:_capPayId,processInstanceId:processInstanceId},
				url: '<%=path%>/capPay/flow/cancelPay.do',
				beforeSend: function(){
				     wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING,SQ_type:"waitting"});
				},
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 UIUtils.alertSuccess(msg.info);
						 window.location.reload();
					 }else{
						 UIUtils.alertError(msg.info);
					 }
				}
			});
		});
	}

	var processInstanceId = '${proIntId}';
	var taskId = '${taskId}';
	var taskDefKey = '${taskDefKey}';
	var taskNm = '${taskNm}';
	var isAuditNode = '${isAuditNode}';
	var btnFlag = '${btnFlag}';
	var hjzxFlag = '${hjzxFlag}';
	var kjshFlag = '${kjshFlag}';
	var zjlFlag = '${zjlFlag}';
	var zjbFlag = '${zjbFlag}';
	var cnFlag = '${cnFlag}';
	var xsFlag = '${xsFlag}';
	var spFlag = '${spFlag}';
	var dyFlag = '${dyFlag}';
	var ctrlKey = '${ctrlKey}';
	var isCPCW = '${isCPCW}';
	var isGpsNode = '${isGpsNode}';
	//当前tab刷新
	function callback() {
        if(grid){
        	grid.reload();
        }
    }
    function toPayFlowAdditionalPage(_payId){
    	var parms = "capPayId="+_payId+"&processInstanceId="+processInstanceId+"&taskId="+taskId+"&taskDefKey="+taskDefKey+"&taskNm="+taskNm;
    		parms += "&isAuditNode="+isAuditNode+"&btnFlag="+btnFlag+"&hjzxFlag="+hjzxFlag+"&kjshFlag="+kjshFlag+"&zjlFlag="+zjlFlag;
    		parms += "&zjbFlag="+zjbFlag+"&cnFlag="+cnFlag+"&xsFlag="+xsFlag+"&ctrlKey="+ctrlKey;
    		parms += "&isCPCW="+isCPCW;
			parms += "&isGpsNode="+isGpsNode;
    		parms += "&checkSp=${checkSp}&checkDy=${checkDy}";
    		parms += "&isNeedCallback=1";//执行collback 刷新列表
    		parms += "&QZTX=${QZTX}";
    		parms += "&addReturnInfo=${addReturnInfo}";
    		parms += "&confirmPay=${confirmPay}";
    		parms += "&version=${version}";
    		parms += "&addReturnInfo_rebate=${addReturnInfo_rebate}";
    		parms += "&modifyRebateBank=${modifyRebateBank}";
    		parms += "&saveDueDate=${saveDueDate}";
    		parms += "&mdfCntTypCd=${mdfCntTypCd}";
    		parms += "&saveOrgBizOpnCd=${saveOrgBizOpnCd}";
    		parms += "&assetCd=${assetCd}";
    	var version = '${version}';
    	var isNeedAddTime = '${isNeedAddTime}';
    	if(version==3){
	    	Add_navTab('payFlowAdditionalPage'+_payId,'放款详细',"<%=path%>/capital/capPayInfo/toAddPage.do?isAddBank=${isAddBank}&accCtrl=${accCtrl}&ctrlKey=${ctrlKey}&isAddPayerStatusCd=${isAddPayerStatusCd}&id="+_payId, callback);
    	}else if(isNeedAddTime==1){  // 呈报人修改交车日期
    		Add_navTab('payFlowAdditionalPage'+_payId,'放款详细',"<%=path%>/capital/capPayInfo/toAddPage.do?isNeedAddTime=1&accCtrl=0&ctrlKey=3&id="+_payId, callback);
    	}else{
	    	Add_navTab('payFlowAdditionalPage'+_payId,'放款详细',"<%=path%>/capPay/flow/toAdditionalInfoPage.do?"+parms, callback);
    	}
    }
    //资料
    function toPrjFileInfo(){
        Add_navTab("addPrjFileInfo"+prjId, "项目资料", '<%=path%>/project/prjFileInfo/toFileInfoListPage.do?prjId='+prjId+'&ctrlKey='+ctrlKey);
    }

    function statistical(){
        Add_navTab('prjBscInfoForInstitution'+_projectId, "敞口统计","<%=path%>/exposure/capPrjArInfo/toExposureCapPrjArInfoPage.do?prjId="+prjId+"&ctrlKey="+ctrlKey+"&exposureSource="+exposureSource);
    }
    
    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    function kjhexiaoshouqi(){
    	Add_navTab("kjhexiao"+prjId, "首期款核销资金信息", '<%=path%>/capital/capFund/toAddFundPage.do?prjId='+prjId);
    }
  //添加第三方联系人信息
	function addEmergencyContact(){
		var detailFlag = false;
		Add_navTab( 'linkman_info_add','第三方联系人信息','<%=path%>/project/prjbscinfo/toAddEmergencyContactList.do?isFlow=1&detailFlag='+detailFlag+'&prj_id='+prjId,callback);
	}
	//查看第三方联系人信息
	function LookEmergencyContact(){
		var detailFlag = true;
		Add_navTab( 'linkman_info_add','第三方联系人信息','<%=path%>/project/prjbscinfo/toAddEmergencyContactList.do?isFlow=1&detailFlag='+detailFlag+'&prj_id='+prjId,callback);
	}  
  //后续回访
  var visitId = "${visitId}";
    function toFlowVisitAdd (){
    	if(!visitId || visitId==""){
    		top.$.ligerDialog.SQalert({content:"请先维护回访记录基本信息", SQ_type: "warning"});
    		return;
    	} 
    	var isDetail = 0;
    	$.ligerDialog.SQopen({
            width: 1100,
            height:500,
            title : '后续回访记录',
            url:'<%=path%>/audit/audReturnVisit/toFlowVisitAddPage.do?visitId='+visitId+'&prjId='+prjId+'&isDetail='+isDetail,
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok',
                    onclick: function (item, Dialog) {
                        if (Dialog.onOk) Dialog.onOk();
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                    onclick: function (item, Dialog) {
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
//        Add_navTab("flowVisitInfo"+visitId, "后续回访记录", '<%=path%>/audit/audReturnVisit/toFlowVisitAddPage.do?visitId='+visitId+'&projectId='+_projectId+'&isDetail='+isDetail);
    }
    function LookFlowVisitAdd (){
    	var isDetail = 1;
    	$.ligerDialog.SQopen({
            width: 1100,
            height:500,
            title : '后续回访记录',
            url:'<%=path%>/audit/audReturnVisit/toFlowVisitAddPage.do?visitId='+visitId+'&prjId='+prjId+'&isDetail='+isDetail,
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok',
                    onclick: function (item, Dialog) {
                        if (Dialog.onOk) Dialog.onOk();
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                    onclick: function (item, Dialog) {
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
//        Add_navTab("flowVisitInfo"+visitId, "后续回访记录", '<%=path%>/audit/audReturnVisit/toFlowVisitAddPage.do?visitId='+visitId+'&projectId='+_projectId+'&isDetail='+isDetail);
    }
 //保存抵押权人名称
    function addpledgeeAuthNm(){
    	var prjPrdDtlId ;
    	var  manager  = $("#ligergrid1").ligerGetGridManager();
		var data = manager.getSelecteds();//获取选中行
		 if (data.length ==0){ alert('请选择行');  return;}
		 var parms=JSON.stringify(data);
		 var jsonObj =  JSON.parse(parms);
		 for(var i=0;i<jsonObj.length;i++){
		 if(jsonObj[i] != ""){
			 prjPrdDtlId = jsonObj[i].prjPrdDtlId
		 }  
		}
    	//var pledgeeAuthNm = $('#pledgee Select option:selected') .val();//选中的值
    	var pledgeeAuthNm= document.getElementById("pledgeeAuthNm").value; 
    	 var wait_dialog;
    	$.ajax({
    		type: 'post',
			dataType:'json',
			data:{pledgeeAuthNm:pledgeeAuthNm,id:prjPrdDtlId},
			url:'<%=path%>/project/prjprdmtg/addpledgeeAuthNm.do',
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
		    success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
				 }else{
					 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
				 }
			}
    	})
    	
    }
//展示项目风险审核提醒
function ctrlPrjRskAudWarnShow() {
	if (null != showPrjRskAudWarn && 'true' == showPrjRskAudWarn) {
		var rskParams = {};
		rskParams.prjId = prjId;
		$.ajax({
			type: 'get',
			dataType:'json',
			data:rskParams,
			url: '<%=path%>/project/prjRskAudWarnRec/searchPrjRskWarnRec.do',
			success:function(msg){
				if(1 == msg.success){
					// 初始化表格
					if (msg.data && msg.data != null) {
						$("#prjRskAudWarnDiv").removeAttr("style");
						inintPrjRskAudWarnGrid(msg.data);
					} else {
						$("#prjRskAudWarnDiv").hide();
					}
				}
			}
		});
	}
}
//初始化项目风险审核提醒列表
function inintPrjRskAudWarnGrid(rskList) {
	$("#ligergrid_prjRskAudWarn").ligerGrid({
		data:rskList,
		dataAction:'local',
		columns: [
			{ display: '名称', name: 'dataNm', minWidth: 140 , enabledSort:true},
			{ display: '主体类型', name: 'dataTypCdNm', minWidth: 80 , enabledSort:true},
			{ display: '敞口总计(元)', name: 'totExpoAmt', minWidth: 140, enabledSort: false,
				render: function (rowdata, index, value) {
					return FormatMoney(rowdata.totExpoAmt / 100);
				}
			},
			{ display: '风险审核提醒', name: 'rskDesc', minWidth: 500 , enabledSort:true}
		],
		// pageSize:100,
		root:'rows',
		record:'total',
		hideLoadButton : true,
		width:'100%',
		// height:100,
		heightDiff:-2,
		rownumbers:true,
		usePagerOnLessPagesize: false,
		usePager: false
	});
	prjRskAudWarnGrid = liger.get("ligergrid_prjRskAudWarn");
}
</script>

</body>
</html>
